import QuickTool from '@/utils/Engineering/QuickTool';
import { host } from '@/utils/web.domain.config';
import { maintableOperateExpandList } from '../main.data';

const operationList = [
  'handleOperaateJump',
  'handleModalEdit',
  'handleSingleCopy',
  'handleQuickEdit',
  'handleSingleQuickEdit',
  'handleModalSubmit',
  'handleSingleDelete',
];

const apiPath = {
  submitDataBaseURL: '/api/common/sys_form_set',
  getDatasourceURL: `/api/common/sys_form_set/page`,
  basis: 'id',
};

const extraData = {
  __sent_data_diff_cover_field: 'code',
};

const pagination = { pageSize: 10, current: 1 };

const popupForm = {
  open_type: 'Drawer',
  width: '65%',
};

const fieldList = [
  {
    form_type: 'Input',
    title_or_label: '标题',
    dataIndex_or_field: 'title',
    key: 'title',
    placeholder: '',
    width: 120,
    col: 12,
    fixed: 'left',
    initialValue: '',
    ellipsis: true,
    list: [],
  },
  {
    form_type: 'Input',
    title_or_label: QuickTool.tooltip({
      title: 'UUID代码',
      help: 'UUID代码不可以为空',
      required: true,
    }),
    dataIndex_or_field: 'code',
    key: 'code',
    placeholder: '',
    width: 180,
    col: 12,
    initialValue: '',
    list: [],
  },
  {
    form_type: 'Input',
    title_or_label: QuickTool.tooltip({
      title: '回调api',
      help: '成功后回调api不可以为空',
      required: true,
    }),
    dataIndex_or_field: 'callback_url',
    key: 'callback_url',
    placeholder: '',
    width: 180,
    col: 12,
    initialValue: '',
    list: [],
  },
  {
    form_type: 'Select',
    title_or_label: QuickTool.tooltip({
      title: '打开方式',
      help: '打开方式不可以为空',
      required: true,
    }),
    dataIndex_or_field: 'open_mode',
    key: 'open_mode',
    placeholder: '',
    width: 180,
    col: 12,
    initialValue: '',
    list: [
      { value: 'Modal', name: '弹窗' },
      { value: 'Drawer', name: '抽屉' },
    ],
  },
  {
    form_type: 'Select',
    title_or_label: QuickTool.tooltip({ title: '布局', help: '布局不可以为空', required: true }),
    dataIndex_or_field: 'layout',
    key: 'layout',
    placeholder: '',
    width: 180,
    col: 12,
    initialValue: '',
    list: [
      { value: 'horizontal', name: '水平' },
      { value: 'inline', name: '行内' },
      { value: 'vertical', name: '垂直' },
    ],
  },
  {
    form_type: 'Input',
    title_or_label: QuickTool.tooltip({ title: '宽度', help: '支持数字和百分比', required: true }),
    dataIndex_or_field: 'width',
    key: 'width',
    placeholder: '',
    width: 180,
    col: 12,
    initialValue: '',
    list: [
      { value: 'horizontal', name: '水平' },
      { value: 'inline', name: '行内' },
      { value: 'vertical', name: '垂直' },
    ],
  },
  {
    form_type: 'Switch',
    title_or_label: '自动关闭',
    dataIndex_or_field: 'is_auto_close',
    key: 'is_auto_close',
    placeholder: '',
    width: 80,
    col: 12,
    initialValue: '',
    list: [],
  },
  {
    form_type: 'Switch',
    title_or_label: '右上角关闭',
    dataIndex_or_field: 'closable',
    key: 'closable',
    placeholder: '',
    width: 120,
    col: 12,
    initialValue: '',
    list: [],
  },
  {
    form_type: 'Input',
    title_or_label: QuickTool.tooltip({
      title: '嵌套子表单code',
      help: '嵌套子表单code',
      required: true,
    }),
    dataIndex_or_field: 'expanded_code',
    key: 'expanded_code',
    placeholder: '',
    width: 180,
    col: 12,
    initialValue: '',
    list: [],
  },
  {
    form_type: 'Select',
    title_or_label: QuickTool.tooltip({
      title: 'label对齐方式',
      help: 'label对齐方式',
      required: true,
    }),
    dataIndex_or_field: 'labelAligin',
    key: 'labelAligin',
    placeholder: '',
    width: 180,
    col: 12,
    initialValue: '',
    list: [
      { value: 'left', name: '左对齐' },
      { value: 'right', name: '右对齐' },
    ],
  },
  {
    form_type: 'Select',
    title_or_label: 'Drawer方向',
    dataIndex_or_field: 'placement',
    key: 'placement',
    placeholder: '',
    width: 160,
    col: 12,
    initialValue: '',
    list: [
      { value: 'top', name: 'top' },
      { value: 'bottom', name: 'bottom' },
      { value: 'left', name: 'left' },
      { value: 'right', name: 'right' },
    ],
  },
  {
    form_type: 'Input',
    title_or_label: QuickTool.tooltip({
      title: 'api地址',
      help: '保存的api地址不可以为空',
      required: true,
    }),
    dataIndex_or_field: 'data_url',
    key: 'data_url',
    placeholder: '',
    width: 200,
    col: 24,
    initialValue: '',
    list: [],
  },
];

const tableOperateExpandList = [maintableOperateExpandList.FormFieldSetting];

const initialSearchList = [
  { ...fieldList[1], col: 6 },
  { ...fieldList[0], col: 6 },
  { form_type: '__operate', custom_sort: true },
];

const dataSource = [
  {
    sys_form_set_code: 'f97c6421decb',
    label: '内容发布',
    data_url: '/api/common/vw_baade_notice/page',
    placeholder: '请输入标签名称',
    size: 'middle',
    required: 1,
    tooltip: '发布内容的东西',
    rowKey: 'id',
    is_pagination: 0,
    is_add: 1,
    is_delete: 1,
    expanded_code: '',
    delete_url: '',
    editable: false,
    sort: 1,
  },
  {
    sys_form_set_code: 'f97c6421decb',
    label: '内容发布',
    data_url: '/api/common/vw_baade_notice/page',
    placeholder: '请输入标签名称',
    size: 'middle',
    required: 1,
    tooltip: '发布内容的东西',
    rowKey: 'id',
    is_pagination: 0,
    is_add: 1,
    is_delete: 1,
    expanded_code: '',
    delete_url: '',
    editable: false,
    sort: 2,
    field: 'content',
    form_type: 'Input',
  },
];

export {
  fieldList,
  initialSearchList,
  dataSource,
  apiPath,
  tableOperateExpandList,
  pagination,
  extraData,
  operationList,
  popupForm,
};
